Conversation
…lock Adapted from the moongatev2/.NET Foundation TLS array pool. Improvements over the source: Environment.TickCount64 instead of DateTime.UtcNow for trim timestamps, an internal TrimCore(milliseconds, pressure) seam for deterministic tests, consistent local usage in Return, and full XML docs including the single-threaded contract.
…docs Changed class-level XML remarks from paramref (invalid for class-level parameters) to plain code tag. CS1734 warning now cleared in Release builds. Verified: dotnet build Release 0 errors, CS1734 gone (2 pre-existing warnings remain).
…pooled formattable ValueStringBuilder and RawInterpolatedStringHandler are ported from the .NET Foundation adaptations in moongatev2 (dual-pool mt switch kept, the unsafe char* overload dropped). PooledArraySpanFormattable is a clean rewrite with an explicit single-use TryFormat contract.
Clean-room implementations with the moongatev2 surface: StartsWithOrdinal, EndsWithOrdinal and friends on strings and spans, Insensitive* mirrors, plus Capitalize, Wrap, IndentMultiline, TrimMultiline, IndexOfTerminator, Remove/ReplaceAny with StringComparison, ToPooledArray and AppendSpaceWithArticle on ValueStringBuilder. Remove skips the full match length and rejects small buffers with ArgumentException.
…e ReplaceAny span lengths
Covers STArrayPool vs ArrayPool.Shared guidance, the single-threaded contract, trimming behavior, ValueStringBuilder usage and the string helper families; links from the Core README.
Removes CollectionExtensions.RandomElement (collides with the existing RandomExtensions family with contradictory empty-collection semantics), makes ValueStringBuilder.Replace/ReplaceAny honor startIndex/count, hardens the PooledArraySpanFormattable implicit string operator against double pool returns, and aligns docs and the MIT header position.
feat(core): buffers stack and string helpers ported from moongatev2
| "An incorrectly written provider said it implemented ICustomFormatter, and then didn't" | ||
| ); | ||
|
|
||
| if (formatter?.Format(format, value, _provider) is string customFormatted) |
| /// </summary> | ||
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| public static int IndexOfTerminator(this Span<byte> buffer, int sizeT) | ||
| => ((ReadOnlySpan<byte>)buffer).IndexOfTerminator(sizeT); |
| [InlineData(new byte[] { 65, 66, 67 }, 1, -1)] | ||
| [InlineData(new byte[] { 65, 0, 0, 0, 66, 0 }, 2, 2)] | ||
| public void IndexOfTerminator_FindsNullTerminatorScaledBySize(byte[] buffer, int sizeT, int expected) | ||
| => Assert.Equal(expected, ((ReadOnlySpan<byte>)buffer).IndexOfTerminator(sizeT)); |
| Gen2GcCallback.Register(o => ((STArrayPool<T>)o).Trim(), this); | ||
| } | ||
|
|
||
| return _cacheBuckets = buckets; |
Comment on lines
+266
to
+297
| foreach (var word in text.Split(' ', StringSplitOptions.RemoveEmptyEntries)) | ||
| { | ||
| var remaining = word.AsSpan(); | ||
|
|
||
| while (!remaining.IsEmpty) | ||
| { | ||
| var separatorLength = current.Length == 0 ? 0 : 1; | ||
| var available = perLine - current.Length - separatorLength; | ||
|
|
||
| if (remaining.Length <= available) | ||
| { | ||
| current.Append(current.Length == 0 ? string.Empty : " ").Append(remaining); | ||
| remaining = default; | ||
| } | ||
| else if (current.Length == 0) | ||
| { | ||
| // Hard-break a word longer than a whole line. | ||
| current.Append(remaining[..perLine]); | ||
| remaining = remaining[perLine..]; | ||
| } | ||
| else | ||
| { | ||
| lines.Add(current.ToString()); | ||
| current.Clear(); | ||
|
|
||
| if (lines.Count == maxLines) | ||
| { | ||
| return lines; | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Promotes develop to main for the 0.22.0 release:
Test plan